package com.flyqiu.flow.boot;

import com.flyqiu.common.user.DefaultFlyQiuUser;
import com.flyqiu.flow.api.candidate.FlowCandidateContext;
import com.flyqiu.flow.api.candidate.FlowCandidateLoad;
import com.flyqiu.flow.api.candidate.FlowInstCandidateContext;
import com.flyqiu.flow.model.entity.ru.ProcRuUserTask;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

@Component
public class DefUserLoad implements FlowCandidateLoad<DefaultFlyQiuUser, FlowCandidateContext, FlowInstCandidateContext> {
    @Override
    public String getGroupKey() {
        return "default";
    }

    @Override
    public String getValue() {
        return "fix";
    }

    /**
     * 加载当前任务办理人
     *
     * @param candidateContext 候选人上下文信息
     * @return
     */
    @Override
    public Collection<DefaultFlyQiuUser> loadInstCandidates(FlowInstCandidateContext candidateContext) {
        ProcRuUserTask userTaskInst = candidateContext.getUserTaskInst();
        System.out.printf("process:候选人加载:userTask：%s,加载候选用户信息%n", userTaskInst.getTaskDefKey());
        List<DefaultFlyQiuUser> result = new ArrayList<>();
        DefaultFlyQiuUser defaultCandidateUser = new DefaultFlyQiuUser();
        defaultCandidateUser.setUserId("test");
        defaultCandidateUser.setNickName("测试用户");
        defaultCandidateUser.setUserType("test");
        result.add(defaultCandidateUser);
        DefaultFlyQiuUser defaultCandidateUser2 = new DefaultFlyQiuUser();
        defaultCandidateUser2.setUserId("test2");
        defaultCandidateUser2.setNickName("测试用户2");
        defaultCandidateUser2.setUserType("test2");
        result.add(defaultCandidateUser2);
        return result;
    }

    @Override
    public Collection<DefaultFlyQiuUser> loadElementCandidates(FlowCandidateContext candidateContext) {
        return null;
    }


}
